package oo

import (
	"elegantGo/chapter02-1/pkg/validate"
)

type Phone struct {
	value string
}

func (o *Phone) SetValue(v string) {
	o.value = v
}

func (o *Phone) Value() string {
	return o.value
}

func (o *Phone) IsValid() bool {
	return validate.Var(o.value, "number,len=11,startswith=1,startsnotwith=11,startsnotwith=12") == nil
}

func (o *Phone) Mask() string {
	return o.value[0:4] + "****" + o.value[8:11]
}

func (o *Phone) GenNickname() string {
	return o.Mask()
}
